package com.wangjie.order.config;

import feign.Logger;
import feign.Retryer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class OrderServiceConfig {
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate() {
        return new RestTemplate();
    }

    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

    /**
     * feign超时重试机制(不配置默认不重试)
     *
     * public Default() {
     *      this(100L, TimeUnit.SECONDS.toMillis(1L), 5);
     * }
     */
    @Bean
    public Retryer retryer() {
        return new Retryer.Default();
    }
}
